package com.jackeysun.common.text

import android.content.Context
import android.graphics.Color
import android.graphics.Rect
import android.text.Spannable
import android.widget.PopupWindow

/**
 *   Created by sunxunchao on 2021/12/31.
 */

interface IFloatWindow {
    fun getFloatWindow(): PopupWindow
    fun isShowing(): Boolean

    fun showAsDropDown(anchor: IViewProtocol, gravity: Int, xoff: Int, yoff: Int)
    fun showAtLocation(anchor: IViewProtocol, gravity: Int, x: Int, y: Int)
    fun update(x: Int, y: Int, width: Int, height: Int, force: Boolean)
    fun dismiss()
    fun getHeight(): Int
    fun getWidth(): Int
    fun setOnDismissListener(onDismissListener: PopupWindow.OnDismissListener)
}

interface IViewProtocol {

    fun getContext(): Context
    fun getText(): CharSequence

    // 获取当前选中的文本
    fun getSelectedText(): CharSequence?
    fun getSelectRect(): Rect
    fun getTouchX(): Float
    fun getTouchY(): Float
    fun getLocationInWindow(): IntArray
}

interface OnSelectListener{
    fun onSelected(selectText: CharSequence?)
}


data class SelectionInfo(
    var mSpan: Any? = null,
    var mStart: Int = 0,
    var mEnd: Int = 0,
    var mSpannable: Spannable? = null,
    var backgroundColor: Int = Color.parseColor("#4DFED400")
)